package com.example.campsystem.controller;

import com.example.campsystem.entity.CustomApi;
import com.example.campsystem.entity.Cities;
import com.example.campsystem.service.CitiesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class CitiesController {
    @Autowired
    private CitiesService citiesService;
    @GetMapping("/cities")
    public ResponseEntity<CustomApi> getCities() {
        CustomApi customApi = new CustomApi();
        List<Cities> citiesList = citiesService.getCities();
        customApi.setCode(200);
        customApi.setMsg("success");
        customApi.setData(citiesList);
        return new ResponseEntity<>(customApi, HttpStatus.OK);
    }
}
